
//
//  MCBaseApiRequstModel.m
//  ZXZX
//
//  Created by menhao on 2018/8/15.
//  Copyright © 2018年 TLYL01. All rights reserved.
//


#import "MCApiBaseModel.h"

@interface MCApiBaseModel()<ApiManagerCallBackProtocol,ApiManagerProvider,ApiManagerProtocol>

@property (nonatomic,strong) ApiBaseManager *baseManager;

@end

@implementation MCApiBaseModel

-(BOOL)isShowHud{
    return YES;
}
- (BOOL)isShowError{
    return NO;
}
- (BOOL)isShowNoNet{
    return NO;
}
- (BOOL)isShowNodata{
    return NO;
}

- (enum ManagerRequestMethod)requestMethod{
    
    return ManagerRequestMethodRequestMethodRestPOST;
}

- (enum APIResponseDataType)responseDataType{
    
    return APIResponseDataTypeJson;
}


- (void)refreashDataAndShow{
    
    ApiBaseManager *baseManager = [[ApiBaseManager alloc] initWithUrlProvider:self];
    self.baseManager = baseManager;
    baseManager.apiCallBackDelegate = self;
    baseManager.requestCustomizeDelegate = self;
    [baseManager loadData];
    
    
}
- (void)cancellAllRequests{
    [self.baseManager cancellAllRequests];
}
- (NSDictionary<NSString *,NSString *> *)headerForManagerWithManager:(ApiBaseManager *)manager{
    NSString * Token=@"";
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"token"]) {
        Token=[[NSUserDefaults standardUserDefaults] objectForKey:@"token"];
    }
    return @{@"token":Token,@"platformCode":@"5"};
}

- (NSString *)urlPathComponentForManagerWithManager:(ApiBaseManager *)manager{
    
    return @"";
}

- (NSDictionary<NSString *,id> *)parametersForManagerWithManager:(ApiBaseManager *)manager{
    
    
//    return @{};
    NSDictionary *dic =@{};
    NSString *jsonStr = [dic convertToJsonData];
    return @{@"params":jsonStr
             };
    
}

- (void)managerCallAPIDidSuccessWithManager:(ApiBaseManager *)manager{
//    [BKIndicationView dismiss];
    if (self.callBackSuccessBlock) {
        self.callBackSuccessBlock(manager.ResponseRawData);
    }
    
}

- (void)managerCallAPIDidFailedWithManager:(ApiBaseManager *)manager errorCode:(NSString *)errorCode{
//    [BKIndicationView dismiss];
    if (self.callBackFailedBlock) {
        self.callBackFailedBlock(manager.ResponseRawData, errorCode);
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}
- (id)valueForUndefinedKey:(NSString *)key{
    return @"";
}
@end
